package com.prik.factory.abs.pizza;

import com.prik.factory.abs.ingredient.PizzaIngredientFactory;

/**
 * @description: 芝士披萨
 * @author: prik
 * @create: 2019-07-31
 **/
public class CheesePizza extends Pizza {

    PizzaIngredientFactory ingredientFactory;

    /**
     * 构造器注入工厂
     *
     * @param ingredientFactory
     */
    public CheesePizza(PizzaIngredientFactory ingredientFactory) {
        this.ingredientFactory = ingredientFactory;
    }

    /**
     * pizza无需关心到底是什么类型的原料工厂，只要是原料工厂就行
     */
    @Override
    public void prepare() {
        System.out.println("原料准备中");
        // 为基类属性赋值
        cheese = ingredientFactory.createCheese();
        pepperoni = ingredientFactory.createPepperoni();
    }
}